package cn.codeforfun.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * Author WangBin
 * Email 253498229@qq.com
 * Created on 2017/6/1 17:37
 * version 1.0.0
 */
public class SpringUtil {
  public static HttpServletRequest getRequest() {
    HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    return request;
  }

  public static HttpSession getSession() {
    HttpSession session = SpringUtil.getRequest().getSession();
    return session;
  }
}
